package com.gis.sql;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.gis.core.Lib;

public class SQLLib implements Lib {
	
	private static List<String> dbIgnore = new ArrayList<String>();
	
	private SQLLib() {
		dbIgnore.add("information_schema");
		dbIgnore.add("mysql");
		dbIgnore.add("performance_schema");
	}
	
	public static List<String> listDatabases(DBConnection conn) {
		List<String> databases = new ArrayList<String>();
		String query = "";
		
		if (conn.getDBType() == DBType.MYSQL) {
			query = "show databases";
		}
		
		conn.connect();
		ResultSet results = conn.query(query);
		
		if (results == null) {
			return null;
		}
		
		try {
			while (results.next()) {
				final String db = results.getString("Database");
				if (!dbIgnore.contains(db)) {
					databases.add(db);
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return databases;
	}
	
	public List<String> listColumns(String database, DBConnection conn) {
		List<String> columns = new ArrayList<String>();
		conn.connect();
		
		conn.query(`)
	}
}
